package org.jsola.hr.task;

import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.xxl.job.core.log.XxlJobLogger;
import lombok.extern.slf4j.Slf4j;
import org.jsola.hr.service.IAttendRuleService;
import org.jsola.hr.service.ICrmCustomerInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * CRM拜访超时处理
 * 定时任务：根据考勤规则和考勤日历创建定时任务给用户发送打卡提醒（公众号推送）
 * @author zdd
 */
@Component
@Slf4j
public class CrmVisitTimeoutTask {

    @Autowired
    private ICrmCustomerInfoService crmCustomerInfoService;

    /**
     * CRM拜访超时处理
     */
    @XxlJob("visitTimeoutTask")
    public ReturnT<String> visitTimeoutTask(String params) {
        XxlJobLogger.log("==========定时任务开始: 处理拜访超时数据");
        try {
            crmCustomerInfoService.getTimeOutCustomers();
        } catch (Exception e) {
            XxlJobLogger.log("==========定时任务失败: 处理拜访超时数据,失败原因 : {}", e.getMessage());
            return ReturnT.FAIL;
        }
        XxlJobLogger.log("==========定时任务结束: 处理拜访超时数据");
        return ReturnT.SUCCESS;
    }

}